/*
 * Copyright (C) 2013
 * Shopping
 */
package com.mshopping.app.manager;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * This class is used for 线程池
 * 
 * @author liuhuan
 * @version 1.0, 2013-9-1 下午6:26:55
 */
public class ThreadPoolManager {

	private static ThreadPoolManager manager = null;
	private ExecutorService service = null;

	private ThreadPoolManager() {
		int num = Runtime.getRuntime().availableProcessors();
		service = Executors.newFixedThreadPool(num * 2);
	}

	public static ThreadPoolManager getInstance() {
		if (manager == null) {
			manager = new ThreadPoolManager();
		}
		return manager;
	}

	public void addTask(Runnable runnable) {
		service.submit(runnable);
	}
}
